<template>
  <div>
    <!-- 轮播图 -->
    <div class="rabanner">
      <div @click="$router.push('/userinfo')" class="dttop">
        <span class="iconfont icon-zuoyoujiantou">电台</span>
        <!-- <span></span> -->
      </div>
      <div class="imgs">
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
          <van-swipe-item v-for="(item, index) in djlist" :key="index">
            <img :src="item.pic" />
          </van-swipe-item>
        </van-swipe>
      </div>
    </div>
    <!-- 分类列表 -->
    <div class="radiotype">
      <ul>
        <li>
          <span class="iconfont icon-jiemu"></span>
          <p>节目</p>
        </li>
        <li @click="$router.push('/hotaudio')">
          <span class="iconfont icon-diantai1"></span>
          <p>热门电台</p>
        </li>
        <li>
          <span class="iconfont icon-dingyue"></span>
          <p>订阅</p>
        </li>
        <li>
          <span class="iconfont icon-fenlei"></span>
          <p>分类</p>
        </li>
        <li>
          <span class="iconfont icon-jingpin"></span>
          <p>付费精品</p>
        </li>
        <li>
          <span class="iconfont icon-zhubo"></span>
          <p>最热主播</p>
        </li>
      </ul>
    </div>
    <!-- 今日优选 -->
    <div class="tada">
      <div>
        <span>今日优选</span>
        <span class="iconfont icon-zuo"></span>
      </div>

      <div class="youx">
        <div class="youxbox" v-for="(item, index) in perlist" :key="index">
          <div
            class="yimg"
            :style="'background-image: url(' + item.picUrl + ')'"
          ></div>
          <span>{{ item.name }}</span>
          <p>{{ item.lastProgramName }}</p>
        </div>
      </div>
    </div>
    <!-- 个性推荐 -->
    <div class="recomper">
      <div>
        <span>个性推荐</span>
        <span class="iconfont icon-zuo"></span>
      </div>
      <div class="recbox">
        <div class="tjbox" v-for="(item, index) in recomlist" :key="index">
          <div
            class="tjimg"
            :style="'background-image: url(' + item.picUrl + ')'"
          ></div>
          <p>{{ item.lastProgramName }}</p>
          <span>{{ item.name }}</span>
          <p>{{ item.rcmdText }}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getDjBanner, getPerfered, getPersonaLize } from "../../api/base";
export default {
  data() {
    return {
      djlist: [],
      perlist: [],
      recomlist: [],
    };
  },
  methods: {
    getDjBannerFun() {
      getDjBanner().then((data) => {
        // console.log(data.data);
        this.djlist = data.data;
      });
    },
    getPerferedFun() {
      getPerfered().then((data) => {
        // console.log(data.data);
        this.perlist = data.data;
      });
    },
    getPersonaLizeFun() {
      getPersonaLize().then((data) => {
        console.log(data.data);
        this.recomlist = data.data;
      });
    },
  },
  created() {
    this.getDjBannerFun();
    this.getPerferedFun();
    this.getPersonaLizeFun();
  },
};
</script>

<style lang="less">
.rabanner {
  color: white;
  .dttop {
    height: 50px;
    position: relative;
    background-color: #d4473c;
    .icon-zuoyoujiantou {
    font-size: 18px;
    position: absolute;
    left: 12px;
    top: 12px;
    color: #fff;
  }
  }
  
  &::before {
    content: "";
    display: block;
    height: 124px;
    background-color: #d44439;
    position: absolute;
    width: 100%;
    z-index: -1;
  }
  position: relative;
  .imgs {
    // position: relative;
    left: 0px;
    right: 0px;
    top: 0px;
    margin: auto;
    width: 96%;
    border-radius: 4px;
    overflow: hidden;
    top: 15px;
    img {
      width: 100%;
    }
  }
}
.radiotype {
  height: 150px;
  border: 1px solid #e4e7eb;
  margin: 20px 10px;
  border-radius: 10px;
  background-color: #d44439;
  ul {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    li {
      width: 100px;
      // border: 1px solid black;
      margin-top: 15px;
      text-align: center;
      color: white;
      span {
        font-size: 30px;
      }
      p {
        font-size: 15px;
      }
    }
  }
}
.tada {
  span {
    margin-left: 15px;
  }
  span:last-child {
    float: right;
    margin-top: 3px;
    margin-right: 10px;
  }
  .youx {
    // border: 1px solid black;
    overflow: hidden;
    display: flex;
    justify-content: space-around;
    .youxbox {
      // width: 100px;
      // height: 100px;
      // border: 1px solid black;
      margin-top: 10px;
      border-radius: 10px;
      .yimg {
        width: 100px;
        height: 100px;
        border-radius: 10px;
        background-size: contain;
        margin-left: 13px;
      }
      span {
        width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        float: left;
        font-size: 15px;
      }
      p {
        width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 10px;
        color: #a7a7a7;
        margin-left: 15px;
      }
    }
  }
}
.recomper {
  margin-top: 20px;
  span {
    margin-left: 15px;
  }
  span:last-child {
    float: right;
    margin-top: 3px;
    margin-right: 10px;
  }
  .recbox {
    // height: 100px;
    // border: 1px solid black;
    margin: 10px 10px;
    .tjbox {
      // width: 100px;
      height: 100px;
      // border: 1px solid black;
      border-radius: 10px;
      margin-top: 10px;
      position: relative;
      .tjimg {
        width: 100px;
        height: 100px;
        background-size: cover;
        border-radius: 10px;
      }
      p {
        position: absolute;
        top: 40px;
        left: 116px;
        font-size: 15px;
        color: #808080;
      }
      span {
        width: 100px;
        position: absolute;
        top: 10px;
        left: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 18px;
      }
      p:last-child {
        width: 100px;
        position: absolute;
        top: 65px;
        left: 116px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 15px;
      }
    }
  }
}
</style>